<template>
    <div style="width: 100%">
        <table class="layui-hide" id="autoagent_checkagent_list" lay-filter="autoagent_checkagent_list"></table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="detils">详情</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">审核不通过</a>
        </script>
    </div>
</template>

<script>
import fenxiaoapi from '../../common/fenxiaoserver.js';
		import bus from '../../common/bus';
export default {
    name: 'autoagent_checkagent_list',
    data() {
        return {
            autoagents_list: [],
			table: false
        };
    },
    created() {},
    components: {},
    computed: {},
    mounted() {
        this.getlist();
    },
	activated() {
	    if (!this.table) return;
	    this.table.resize('autoagent_checkagent_list');
	},
    methods: {
        del(obj){
			// /autoagent_checkagent?token=sadfasf&id=1
			var _this = this;
        },
        detils(obj){
            console.log(obj);
            this.$router.push('autoagents_details?id=' + obj.id);
        },
        edit(obj){
			var _this = this;
			fenxiaoapi.AutoAgentNoPass(this,obj.id,function(msgs){
				alert(msgs);
				_this.getlist()
			},function(msgs){
				
			})
        },
        getlist() {
            var _this = this;
            layui.use('table', function () {
                _this.table = layui.table;
                _this.table.render({
                    elem: '#autoagent_checkagent_list',
                    url: _this.url + '/autoagent_checkagent_list',
                    where: { token: _this.vuex_user.token },
                    cellMinWidth: 80,
                    cols: [
                        [
                            { field: 'id',width: 80,title: 'ID', sort: true },
                            { field: 'uname',width: 160, title: '姓名' },
                            { field: 'uphone',width: 160, title: '手机', sort: true },
                            { field: 'product',  title: '意向', sort: true },
							{ field: 'fstate',width: 100,  title: '状态', sort: true },
							{ field: 'faddtime', title: '时间', sort: true },
							{ fixed: 'right', title: '操作', toolbar: '#barDemo' }
                        ]
                    ],
                    height: $('.content').height() - 20,
                    page: true,
                    limit: 10,
                    toolbar: true,
                    parseData: function (res) {
						// console.log(res.code)
						res.data.list.forEach((item,index,array)=>{
						    //执行代码
							item.faddtime = item.faddtime.replace('T',' ')
							if(item.fstate == 'nopass'){
								item.fstate = '<span style="color:red;">未审核</span>';
							}else if(item.fstate == 'ispass'){
								item.fstate = '已审核';
							}else{
								item.fstate = '不通过';
							}
						})
                        return {
                            code: 0, //解析接口状态
                            msg: res.msgs, //解析提示文本
                            count: res.data.nums.nums, //解析数据长度
                            data: res.data.list //解析数据列表
                        };
                    }
                });
				bus.$on('collapse-content', (msg) => {
				    setTimeout(function () {
				        _this.table.resize('autoagent_checkagent_list');
				    }, 300);
				});
                _this.table.on('tool(autoagent_checkagent_list)', function (obj) {
                    var data = obj.data;
                    if (obj.event === 'del') {//删除点击
                        layer.confirm('真的删除行么', function (index) {
                            obj.del();
                            layer.close(index);
                            _this.del(data);
                        });
                    }
                    else if (obj.event === 'detils') {//详情点击
                        _this.detils(data);
                    } else if (obj.event === 'edit') {//编辑点击
                        _this.edit(data);
                    }
                });
            });
        }
    }
};
</script>


<style scoped>
</style>
